# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-06-21
# @File : 9_hook_esNav.py

import frida
import sys


str_host = "127.0.0.1:8877"
manager = frida.get_device_manager()
rdev = manager.add_remote_device(str_host)
session = rdev.attach("唯品会")

scr = """
Java.perform(function () {
    var KeyInfo = Java.use("com.vip.vcsp.KeyInfo");

    KeyInfo.esNav.implementation = function (ctx, str, str2,str3, i10) {
        console.log("-----------------gsNav-----------------");
        console.log("参数==>", str);
        console.log("参数==>", str2);
        console.log("参数==>", str3);
        console.log("参数==>", i10);
        var res = this.esNav(ctx, str, str2,str3, i10);
        console.log("返回的值==>", res);
        return res;
    }
});
"""
script = session.create_script(scr)


def on_message(message, data):
    print(message, data)


script.on("message", on_message)

script.load()
sys.stdin.read()

'''
{
    "app_name": "shop_android",
    "app_version": "7.83.3",
    "client_type": "android",
    "dinfo": "{"ah1":"","ah2":"","ah3":"","ah4":"wifi","ah5":"1440_2712","ah6":1900800,"ah7":8,"ah8":3839950848,"ah9":"Pixel 2 XL","ah10":"","ah11":"","ah12":"","ah13":"","as1":"10","as2":"","as3":"","as4":"2b0ccd53f6b3854c","as5":"","as6":"","as7":"29","ac1":"cef3f807-c9fc-3ceb-a818-74ad1ecd48aa"}",
    "mars_cid": "cef3f807-c9fc-3ceb-a818-74ad1ecd48aa",
    "phone_model": "Pixel 2 XL",
    "session_id": "cef3f807-c9fc-3ceb-a818-74ad1ecd48aa_shop_android_1687334748240",
    "sys_version": "29",
    "vcspKey": "4d9e524ad536c03ff203787cf0dfcd29",
    "vcspToken": "NGQ5ZTUyNGFkNTM2YzAzZmYyMDM3ODdjZjBkZmNkMjl8fHwxNjg5OTI2NzQ4fHx8.6653fd9714fd420d90aca34cc407d4b6"
}
'''
'''
    "dinfo": "{"ah1":"","ah2":"","ah3":"","ah4":"wifi","ah5":"1440_2712","ah6":1900800,"ah7":8,"ah8":3839950848,"ah9":"Pixel 2 XL","ah10":"","ah11":"","ah12":"","ah13":"","as1":"10","as2":"","as3":"","as4":"2b0ccd53f6b3854c","as5":"","as6":"","as7":"29","ac1":"cef3f807-c9fc-3ceb-a818-74ad1ecd48aa"}",
    {
      "ah1": "",
      "ah2": "",
      "ah3": "",
      "ah4": "wifi",
      "ah5": "1440_2712",
      "ah6": 1900800,
      "ah7": 8,
      "ah8": 3839950848,
      "ah9": "Pixel 2 XL",
      "ah10": "",
      "ah11": "",
      "ah12": "",
      "ah13": "",
      "as1": "10",
      "as2": "",
      "as3": "",
      "as4": "2b0ccd53f6b3854c",
      "as5": "",
      "as6": "",
      "as7": "29",
      "ac1": "cef3f807-c9fc-3ceb-a818-74ad1ecd48aa"
    }
'''